#!/bin/bash

databaseName="wikiubb"

echo
echo 'Starting script...'
echo
echo

echo 'Updating repository'
sudo apt-get update
echo 'Finished updating repository'
echo
echo

echo 'Setting up MySQL 5.6'
sudo apt-get install mysql-server-5.6
echo 'Finished setting up MySQL 5.6'
echo
echo

echo 'Setting up Python2.7'
sudo apt-get install python2.7
echo 'Finished setting up Python2.7'
echo
echo

echo 'Setting up Python-dev'
sudo apt-get install python-dev
echo 'Finished setting up Python-dev'
echo
echo

echo 'Setting up libhunspell-dev'
sudo apt-get install libhunspell-dev
echo 'Finished setting up libhunspell-dev'
echo
echo

echo 'Drop database'
mysql -uroot -p -e "drop database if exists $databaseName;"
echo 'Creating database'
mysql -uroot -p -e "create database $databaseName;"
echo 'Database created'
echo
echo

echo 'Creating tables'
mysql $databaseName -uroot -p < create_tables.sql
echo 'Finished creating tables'
echo
echo

echo 'Change dir to the hunspell directory'
cd hunspell-0.2.1/
echo 'Dir changed to the hunspell directory'
echo

echo 'Installing Hunspell'
python setup.py install
echo 'Finished installing Hunspell'
echo
echo

echo 'Change dir one level back'
cd ..
echo 'Dir changed one level back'
echo

echo 'Inserting dumped data'
mysql $databaseName -uroot -p < InsertData.sql
echo 'Finished inserting dumped data'
echo
echo

echo 'Deleting short documents'
mysql $databaseName -uroot -p < deleteShortTexts.sql
echo 'Finished deleting short documents'
echo
echo

echo 'Finished script.'
echo

# sudo apt-get install python-sklearn
# sudo apt-get install python-nltk
# sudo apt-get install python-mysqldb
# nltk.download()  ---> stopwords and unicode-samples
# wget https://bootstrap.pypa.io/ez_setup.py -O - | python
# https://github.com/zikzakmedia/python-mediawiki


